<template>
	<view class="news_detail">
		<text class="title">{{detail.title}}</text>
		<view class="info">
			<text>发表时间：{{detail.pubTime | formatDate}}</text>
			<text>浏览：{{detail.viewCount}}</text>
		</view>
		<view class="content">
			<rich-text :nodes="detail.content"></rich-text>
			<!-- <web-view src="https://www.bilibili.com/video/BV1r54y1Y7Ev/" class="v1">
			</web-view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				detail:{}
			}
		},
		methods: {
			async getNewsDetail(){
				const res = await this.$myRequest({
					url:"/news/getNewsDetailList?id="+this.id
				})
				console.log(res)
				//正则替换图片不满屏问题
				this.detail = res.data[0];
				this.detail.content = res.data[0].content.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
				console.log("this.detail:"+this.detail)
			}
		},
		onLoad(options){
			this.id = options.id;
			this.getNewsDetail();
		}
		
	}
</script>

<style lang="scss">
.news_detail{
	font-size:30rpx ;
	padding: 0 20rpx;
	.title{
		text-align: center;
		width: 100%;
		display: block;
	}
	.info{
		display: flex;
		justify-content: space-between;
		margin-top:30rpx;
	}
	.content{
		margin-top:30rpx;
	}
}
</style>
